#!/bin/bash
#
# lis the most used commands
# usage: topcmd N
# example: topcmd 10

if [ $# -eq 0 ]; then
  N=10
else
  N=$1
fi
cat ~/.bash_history | awk '{CMD[$1]++ ;count++ ;}END {for (a in CMD) print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n $N
